home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
19
/
madtrb11.zip
/
TYPER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-07-13
|
4KB
|
149 lines
Program TYPER;
{
This program is a typewriter emulator for systems with character-based
line printers. Tabs and backspaces are permitted; each line will be
auto-indented, similar to the ^QI option in the Turbo Pascal editor.
Source: "TYPER: A Typewriter Emulator", TUG Lines Volume I, Issue 4
Author: L.P. Levine/Milwaukee, WI/
Application: All operating systems
}
const
version_flag = '103184';
var
i,firstchar:integer;
new_character:char;
text_line:string[100];
function inkey:char; { read a single character from the keyboard }
var
inkeytemp:char;
begin
read(kbd,inkeytemp);
inkey := inkeytemp;
end;
procedure typewriter_init;
begin
{ insert printer initialization here, if needed }
end;
procedure print_out(outchar:char);
{ print a single character to the printer }
begin
write(lst,outchar);
end;
{ Program main body }
begin
{ Initialization }
ClrScr;
GotoXY(1,1);
HighVideo;
write(' ');
LowVideo;
write('Typewriter Emulator, Version ',version_flag,'. ');
writeln('Type CTRL-C to Exit.');
HighVideo;
GotoXY(1,4);
typewriter_init; {Initialize the printer}
text_line := '';
firstchar := 1;
{ Loop Routine }
{accept a character and print it, end with CTRL-C}
while ord(new_character) <> 3 do begin
new_character := inkey;
case new_character of
#127,#8: {Rubout,Backspace; erase the last character, and print
out a BS SP BS.}
begin
if length(text_line) > 0 then
begin
text_line := copy(text_line,1,length(text_line)-1);
print_out(#8);
write(#8,' ',#8)
end;
end;
#13: {Carriage Return; Print the string out}
begin
writeln;
{write a colon, to show system busy. }
write(':');
print_out(#13);
i := 1;
{print out the line. }
while i <= length(text_line) do
begin
print_out(copy(text_line,i,1));
i := i + 1
end;
{find the first non-blank, and tab to it.}
i := length(text_line);
while i <> 0 do
begin
if copy(text_line,i,1) <> ' ' then firstchar := i;
i := i - 1
end;
text_line := '';
i := 1;
print_out(#13); {carriage return}
print_out(#10); {line feed}
{erase the colon and space out. }
write(#8,' ',#8);
while i < firstchar do
begin
write(' ');
print_out(' ');
text_line := text_line + ' ';
i := i + 1
end;
end;
#9: {Horizontal tabulation}
begin
write(' ');
print_out(' ');
text_line := text_line + ' ';
while length(text_line) mod 8 <> 0 do
begin
text_line := text_line + ' ';
write(' ');
print_out(' ')
end;
end;
#3: {Control - C}
begin
writeln;
print_out(#13);
print_out(#10);
print_out(#7);
GotoXY(1,24)
end;
#0..#31:
begin
{Treat all other control characters as nulls.}
end;
else {Accept all other characters}
begin
write(new_character);
text_line := text_line + new_character;
print_out(' ');
end { write a single character to screen }
end {character case }
end {while not CTRL-C}
end.